<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .why {
            width: 200px;
            height: 200px;
            background-color: gold;
        }

        .coderWhy {
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>

<body>
    <div id="app"></div>
    <script src="./renderer.js"></script>

    <script>

        // 1.通过h函数来创建一个vnode
        const vnode = h('div', { class: 'why' }, [
            h('h2', null, "当前计数：100"),
            h('button', { onClick: () => { console.log("+1") } }, "+1"),
        ]);

        // 2.通过mount函数，将vnode挂载到div#app上
        mount(vnode, document.querySelector("#app"));

        setTimeout(() => {
            // 3.创建新的VNode
            const vnode1 = h('div', { class: 'coderWhy', id: "aaaa" }, [
                h('h3', { class: 'myTitle' }, "这是我的标题"),
                h('button', { onClick: console.log("新的打印函数") }, "打印"),
                h('button', { onClick: console.log("新的打印函数") }, "打印2"),
                h('button', { onClick: console.log("新的打印函数") }, "打印3"),
            ]);
            patch(vnode, vnode1);
        }, 2000);
    </script>

</body>

</html>